home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
wtek0693.zip
/
OOPALLEY.ZIP
/
XSTACK.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-22
|
1KB
|
29 lines
#include "point.h"
#include "rect.h"
#include "stack.h"
main()
{
cout << "\nTest class Stack\n";
Rectangle a(0,0,10,10); // create Rectangle, a
Point A(1,2); // create Point, A
Point B(3,4); // create Point, B
Object* C = A.copy(); // C is a generic pointer
// pointing to a copy
// of the Point, A
Stack s(10); // create polymorphic Stack, s
s.push(B); // push Point B onto s
s.push(a); // push Rectangle onto s
s.push(A); // push Point A onto s
cout << s << "\n";
cout << "top compare C = " << s.top()->compare(*C) << "\n";
cout << *(s.pop()) << "\n"; // pop Point and print
cout << *(s.top()) << "\n"; // pop Rectangle and print
s.pop(); // pop B
s.pop(); // should get underflow error
s.pop(); // should not take 4 pops, but it does
}